Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify-parents: add a command to remove redundant parents #4492

Merged
merged 1 commit into from
Oct 8, 2024

Conversation

torquestomp
Copy link
Collaborator

@torquestomp torquestomp commented Sep 17, 2024

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

cli/src/commands/simplify.rs Outdated Show resolved Hide resolved
cli/tests/[email protected] Outdated Show resolved Hide resolved
cli/tests/[email protected] Outdated Show resolved Hide resolved
cli/tests/[email protected] Outdated Show resolved Hide resolved
@samueltardieu
Copy link
Collaborator

samueltardieu commented Sep 18, 2024

I don't want to approve this change myself because I've not followed closely enough the discussions to know the policy about adding new commands. In particular, is "simplify" clear enough, or should it be "simplify-tree", or whatever?

But I would have had a use for it as recently as today, when one of my PR (change A) was merged into main: one of my development subtree was based both on this change A and another unmerged one (change B). After rebasing B onto main, I ended up for my dev subtree parents with a merge between a descendant of main (B) and what was now a parent of main (A). A jj simplify here would have saved me the manual rebasing of my subtree on B only.

In this case it was only one subtree with only two parents, and a simple operation, but with a more complex development tree I can see how it would have been even more useful.

Copy link
Collaborator

@yuja yuja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In particular, is "simplify" clear enough, or should it be "simplify-tree", or whatever?

I don't have a good suggestion, but I feel "simplify" is too generic. If we use "simplify-", "simplify-parents" is probably better.

cli/src/commands/simplify.rs Outdated Show resolved Hide resolved
cli/src/commands/simplify.rs Outdated Show resolved Hide resolved
cli/src/commands/simplify.rs Outdated Show resolved Hide resolved
@torquestomp
Copy link
Collaborator Author

In particular, is "simplify" clear enough, or should it be "simplify-tree", or whatever?

I don't have a good suggestion, but I feel "simplify" is too generic. If we use "simplify-", "simplify-parents" is probably better.

Done, changed to simplify-parents for now.

Idk if the file should still be named 'simplify.rs' to leave room for others, but I changed it to simplify_parents.rs also for now

@thoughtpolice
Copy link
Collaborator

simplify-parents seems rather wordy to be in the top-level namespace, but other than that I think it's fine. I suspect it might be best to go under a utils subcommand or something like we've talked about before, but I'm interested in what other people think.

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@samueltardieu samueltardieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the commit message still contains simplify instead of simplify-parents

@torquestomp
Copy link
Collaborator Author

nit: the commit message still contains simplify instead of simplify-parents

Find and replace, my greatest weakness

@samueltardieu samueltardieu changed the title simplify: add a command to remove redundant parents simplify-parents: add a command to remove redundant parents Sep 19, 2024
@yuja
Copy link
Collaborator

yuja commented Sep 19, 2024

simplify-parents seems rather wordy to be in the top-level namespace, but other than that I think it's fine. I suspect it might be best to go under a utils subcommand or something like we've talked about before, but I'm interested in what other people think.

Yeah. If we had a generic graph reshaping command or command namespace, simplify can be moved there. This could also be rebase --simplify-ancestor-merge, but it's inconvenient if the use case is to eliminate redundant edges created by autorebase.

@ilyagr any thoughts?

cli/src/commands/simplify_parents.rs Outdated Show resolved Hide resolved
cli/src/commands/simplify_parents.rs Outdated Show resolved Hide resolved
@ilyagr
Copy link
Collaborator

ilyagr commented Sep 22, 2024

I think simplify-parents is fine for now, unless we get a better idea.

One alternative I can think of is to have a subcommand, e.g. jj graph simplify-parents or jj graph-util simplify-parents.

Yet another option would be to make jj rebase a namespace with jj rebase source instead of jj rebase -s, and then we could have jj rebase simplify-parents.

Another command that could go into this namespace (or be an option to rebase) is jj reparent-children --from X --to Y (or move-children) that replaces X with Y in the list of any commit's children (without breaking merge commits). I keep meaning to and not quire writing up an FR or PR for it.

@torquestomp
Copy link
Collaborator Author

I like the idea of jj graph simplify-parents, it would probably make sense to also move jj parallelize into this subgroup? (Also is anyone making jj linearize yet, that would also fit here?)

@yuja
Copy link
Collaborator

yuja commented Sep 23, 2024

Operation history is also a "graph", so I think jj graph is still vague.

it would probably make sense to also move jj parallelize into this subgroup?

It might make sense, but I tend to prefer flattened command structure. jj parallelize isn't so ambiguous compared to jj simplify (without -parents/-merge.)

@martinvonz
Copy link
Owner

If we add a graph command category, then it seems like even rebase would belong under it, but if we do that, then basically everyone would create an alias for it anyway.

@ilyagr
Copy link
Collaborator

ilyagr commented Sep 23, 2024

Operation history is also a "graph", so I think jj graph is still vague.

This is a good point. jj commits or jj commitgraph or jj cgraph seem like obvious alternatives, but I'm not sure they are great (jj commit would be better if the current jj commit command did not exist or was renamed). Or we could just accept it and have jj graph, jj evo graph (or evo-graph or evograph), and jj op graph, slimilarly to jj log/evo-log/op log.

If we add a graph command category, then it seems like even rebase would belong under it, but if we do that, then basically everyone would create an alias for it anyway.

I wouldn't mind jj rebase being an alias for jj graph rebase. It'd be unclear whether jj duplicate should also be in jj graph. If it was called jj commit, it'd be easier to make many commands (new, squash, log, etc.) have canonical names like jj commit new.

On the other hand, if we just want the uncommon commands to be in a subcommand, it could be jj graph-utils simplify-parents or jj util graph simplify-parents.


Another idea, based on Yuya's comment is jj simplify parents. But, in any case, we could start with jj simplify-parents.

Copy link
Collaborator

@ilyagr ilyagr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, here are a few bikesheddy comments. I hope they are uncontroversial, but I thought I'd send them out early in just in case there are other opinions.

cli/src/commands/simplify_parents.rs Outdated Show resolved Hide resolved
cli/src/commands/simplify_parents.rs Outdated Show resolved Hide resolved
cli/src/commands/simplify_parents.rs Outdated Show resolved Hide resolved
@ilyagr
Copy link
Collaborator

ilyagr commented Sep 27, 2024

By the way, I agree with this approach of dealing with redundant ancestry overall. It seems more predictable to me than trying to do simplification automatically in some situations. (Well, I suppose, if we have some great ideas about auto-simplification, this PR doesn't prevent us trying to do that too, but I'm not optimistic about that at the moment).

@torquestomp torquestomp force-pushed the simplify branch 2 times, most recently from 0d396cc to 8603641 Compare October 3, 2024 18:23
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@ilyagr ilyagr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all LGTM. The new clippy warning should be easy to fix. Thank you!

@torquestomp torquestomp enabled auto-merge (rebase) October 8, 2024 00:04
@torquestomp torquestomp merged commit 95344f9 into martinvonz:main Oct 8, 2024
18 checks passed
@bnjmnt4n
Copy link
Collaborator

bnjmnt4n commented Oct 8, 2024

Would it be a good idea to set a default revset + configuration for jj simplify-parents (like jj fix)?

@torquestomp torquestomp deleted the simplify branch October 30, 2024 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants